//
//  jExcVLJLCFMineWithdrawViewControllerpBjSQH.m
//  Srb_ios
//
//  Created by Ji on 2018/9/18.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "jExcVLJLCFMineWithdrawViewControllerpBjSQH.h"
#import "ZfZunNJLCFMineWithdrawRecordControllerfUTkiJ.h"
#import "ZDnlTfJLCFMineWithdrawConfirmControllerftiUGb.h"

@interface jExcVLJLCFMineWithdrawViewControllerpBjSQH ()<UITextFieldDelegate>

@property (nonatomic, strong) UITextField *withdrawTextField;

@end

@implementation jExcVLJLCFMineWithdrawViewControllerpBjSQH

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addNavigationBar];
    self.navigationBar.title = @"账户提现";
    
    UIButton *recordBtn = [UIButton buttonWithType:0];
    [recordBtn setTitle:@"提现记录" forState:0];
    [recordBtn setTitleColor:RGB(54, 124, 253) forState:0];
    recordBtn.titleLabel.font = FONT(12);
    [recordBtn sizeToFit];
    recordBtn.centerY = NAVBAR_CENTER_Y;
    recordBtn.right = FULL_WIDTH - 10;
    [recordBtn addTarget:self action:@selector(handleRecord) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationBar addSubview:recordBtn];
    
    self.view.backgroundColor = QTZ_Gray237;
    [self configView];
}

- (void)handleRecord
{
    [[JinLiCaiFuApplicationEntrace shareEntrance].currentNavController pushViewController:[JLCMineWithdrawRecordController new] animated:YES];
}

- (void)configView
{
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 13 + NAVBAR_HEIGHT, FULL_WIDTH, 95)];
    bgView.backgroundColor = QTZ_White;
    bgView.layer.cornerRadius = 10;
    bgView.layer.masksToBounds = YES;
    [self.view addSubview:bgView];
    
    UILabel *withdrawLabel = [UILabel labelWithText:@"提现金额" textColor:QTZ_Gray51 font:FONT(16)];
    withdrawLabel.left = 10;
    withdrawLabel.top = 13;
    [bgView addSubview:withdrawLabel];
    
    UILabel *amountCountLabel = [UILabel labelWithText:@"￥" textColor:QTZ_Gray51 font:FONT(16)];
    amountCountLabel.left = 10;
    amountCountLabel.top = 50;
    [bgView addSubview:amountCountLabel];
    
    self.withdrawTextField = [[UITextField alloc] initWithFrame:CGRectMake(amountCountLabel.right + 5, 0, 200, 20)];
    self.withdrawTextField.font = FONT(15);
    self.withdrawTextField.textColor = Theme_Color;
    self.withdrawTextField.placeholder = @"请输入您的提现金额";
    self.withdrawTextField.keyboardType = UIKeyboardTypeNumberPad;
    self.withdrawTextField.delegate = self;
    self.withdrawTextField.centerY = amountCountLabel.centerY;
    [bgView addSubview:self.withdrawTextField];
    [amountCountLabel.layer addSublayer:[CALayer addLineOriginPoint:CGPointMake(0, amountCountLabel.height + 3) toPoint:CGPointMake(bgView.width - 20, amountCountLabel.height + 3) color:QTZ_Gray237 borderWidth:.5]];
    
    UILabel *TvtacpmoneyLabelIfJqAd = [UILabel new];
    TvtacpmoneyLabelIfJqAd.font = FONT(10);
    TvtacpmoneyLabelIfJqAd.textColor = QTZ_Gray102;
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"可提现金额: %@元", self.amount]];
    [attributeStr addAttribute:NSForegroundColorAttributeName value:Theme_Color range:NSMakeRange(7, self.amount.length)];
    TvtacpmoneyLabelIfJqAd.attributedText = attributeStr;
    [TvtacpmoneyLabelIfJqAd sizeToFit];
    TvtacpmoneyLabelIfJqAd.left = withdrawLabel.left;
    TvtacpmoneyLabelIfJqAd.top = 78;
    [bgView addSubview:TvtacpmoneyLabelIfJqAd];
    
    UIButton *confirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, FULL_HEIGHT - 60, FULL_WIDTH - 76, 40)];
    [confirmBtn setBackgroundColor:Theme_Color];
    confirmBtn.titleLabel.font = FONT(15);
    [confirmBtn setTitle:@"下一步" forState:0];
    [confirmBtn setTitleColor:QTZ_White forState:0];
    confirmBtn.layer.cornerRadius = 5;
    [confirmBtn addTarget:self action:@selector(handleConfirm) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:confirmBtn];
    
}

- (void)handleConfirm
{
    
    if ([self.withdrawTextField.text integerValue] <= [self.amount integerValue]) {
        
        ZDnlTfJLCFMineWithdrawConfirmControllerftiUGb *vc = [ZDnlTfJLCFMineWithdrawConfirmControllerftiUGb new];
        vc.amount = self.withdrawTextField.text;
        [[JinLiCaiFuApplicationEntrace shareEntrance].currentNavController pushViewController:vc animated:YES];
        
    } else {
        [self showNotice:[NSString stringWithFormat:@"可提现金额: %@元", self.amount]];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
    
}


@end
